package com.yang.action;

import com.yang.entity.Productcar;
import com.yang.service.ProductcarService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Date;

@WebServlet("/saveProductcar")
public class ProductcarSaveAction extends HttpServlet {
    ProductcarService productcarService = new ProductcarService();

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Productcar productcar = new Productcar();
        String name = req.getParameter("name");
        productcar.setName(name);
        String url = req.getParameter("url");
        productcar.setUrl(url);
        String price = req.getParameter("price");
        String num = req.getParameter("num");
        productcar.setNum(Integer.parseInt(num));
        String detail = req.getParameter("detail");
        productcar.setDetail(detail);
        String categoryid = req.getParameter("categoryid");
        productcar.setCategoryid(Integer.parseInt(categoryid));
        int num2 = productcarService.saveProductcar(productcar);
        resp.setContentType("text/text;charset=utf-8");
        PrintWriter out = resp.getWriter();
        out.print(num2);
        out.flush();
        out.close();
    }
}

